﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace ucwp7
{
    public class CalClass
    {
        private string mem = "0";

        //========== Function ==========

        public string add_cal(string num1,string num2)
        {
            return (double.Parse(num1) + double.Parse(num2)).ToString();
        }

        public string minus_cal(string num1, string num2)
        {
            return (double.Parse(num1) - double.Parse(num2)).ToString();
        }

        public string multi_cal(string num1, string num2)
        {
            return (double.Parse(num1) * double.Parse(num2)).ToString();
        }

        public string div_cal(string num1, string num2)
        {
            return (double.Parse(num1) / double.Parse(num2)).ToString();
        }

        public string squ_cal(string num1)
        {
            return Math.Sqrt(double.Parse(num1)).ToString();
        }

        public string pow_cal(string num1, string num2)
        {
            return Math.Pow(double.Parse(num1), double.Parse(num2)).ToString();
        }

        //========== Memory ==========

        public void set_memory(string num)
        {
            mem = num;
        }

        public string get_memory()
        {
            return mem;
        }

        public void mem_add(string num)
        {
            double sum = double.Parse(mem);

            sum += double.Parse(num);
            mem = sum.ToString();
        }

        public void mem_sub(string num)
        {
            double sum = double.Parse(mem);

            sum -= double.Parse(num);
            mem = sum.ToString();
        }

        public void mem_clear()
        {
            mem = "0";
        }
    }
}
